
const protecteds = new WeakMap()

class Common {
 constructor(host) {
  this.host = host
  protecteds.set(this, this.host)
}

set host(url) {
  if (!/^https?:\/\//i.test(url)) {
    throw new Error("网址错误");
  }
  protecteds.set(this, url)
}

get host() {
  return protecteds.get(this)
}

}

class Article extends Common {
  lists() {
    return `${this.host}/article`;
  }
}
let article = new Article('http://baidu.com');
console.log(article.lists()); //https://houdunren.com/article
article.host = "https://hdcms.com";
console.log(article.lists()); //https://hdcms.com/article

console.log('-----------------------\n')
console.log(article)
console.log(article.lists()); //https://hdcms.com/article
console.log(protecteds)
